package com.example.designPattern.Proxy;

import java.lang.reflect.Proxy;

/*
 * @Project:com.zh.DesignPattern.Proxy
 * @Creator:Administrator
 * @Description:
 * @Date Created in 11:24 2018/11/18
 */
public class ProxyTest {

    public static void main(String[] args) {
        RealStar realStar = new RealStar();
        StaticProxyStar  proxyStar = new StaticProxyStar(realStar);
        proxyStar.confer();
        proxyStar.signContract();
        proxyStar.bookTicket();
        proxyStar.sing();
        proxyStar.collectMoney();


        DynamicProxyStarHandler handler = new DynamicProxyStarHandler(realStar);

        //IStar proxyInstance = (IStar) Proxy.newProxyInstance(ClassLoader.getSystemClassLoader(), new Class[] { IStar.class }, handler);
        IStar proxyInstance = (IStar) Proxy.newProxyInstance(DynamicProxyStarHandler.class.getClassLoader(), new Class[] { IStar.class }, handler);
        proxyInstance.confer();
        proxyInstance.signContract();
        proxyInstance.bookTicket();
        proxyInstance.sing();
        proxyInstance.collectMoney();


    }
}
